myApp.controller('productController',function($scope,$state,toaster,$serProduct,$localStorage) {
    var ctrl = this;
    ctrl.vm = {
        data:{},
        search:{
            id:'',
            name:'',
            state:'',
            see:'',
            seeImg:$localStorage.orderImg
        },
        searchFn:function(){
            vm.init()
        },
        reset:function(){
            ctrl.vm.search.id='';
            ctrl.vm.search.name='';
            ctrl.vm.search.state='';
            ctrl.vm.search.see='';
            vm.init();
        },
        changeImg:function(){
            $localStorage.orderImg = ctrl.vm.search.seeImg;
        },
        edit:function (id) {
            $state.go('app.changeitem',{id:id})
        }
    };
    $scope.vm={
        page:{}
    };
    /*跳转页面*/
    $scope.pageChanged = function() {
        vm.init($scope.vm.page.current_page)
    };
    /*每页显示数量显示*/
    $scope.placement = {
        options: [5,10,20,50],
        pageSize:5,
        selected: 10,
        changeFn:function(){
            vm.init(0)
        }
    };
    var vm = {
        init:function(page){
            $serProduct.getList({
                page:page||1,
                size:$scope.placement.selected,
                name:  ctrl.vm.search.name||'',
                id: ctrl.vm.search.id||'',
                status:  ctrl.vm.search.state||'',
                is_search:    ctrl.vm.search.see||''
            }).then(function(res){
                if(res.code==1){
                    ctrl.vm.data = res.data;
                    $scope.vm.page = res.addtion_data;
                }else{
                    ctrl.vm.data='';
                    toaster.info('提示',res.message);
                }
            })
        }
    };

    vm.init();
});